<?php
/*
 * main script
* */
function html_master_script_filter(){
?>
<script type="text/javascript" src="./libs/jquery-latest.js"></script>
<script type="text/javascript" src="./libs/jquery.highlight-4.js"></script>
<script src="style/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript">
	function getQueryStrings() { 
		  var assoc  = {};
		  var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
		  var queryString = location.search.substring(1); 
		  var keyValues = queryString.split('&'); 
	
		  for(var i in keyValues) { 
		    var key = keyValues[i].split('=');
		    if (key.length > 1) {
		      assoc[decode(key[0])] = decode(key[1]);
		    }
		  } 
		  return assoc; 
		}	
	/* highlight value when search information*/
	function highlight(container,what,spanClass) {
	    var content = container.innerHTML,
	        pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
	        replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
	        highlighted = content.replace(pattern,replaceWith);
	    return (container.innerHTML = highlighted) !== content;
	}
</script>
<?php 
}
function html_master_script_checkall(){
?>
<script type="text/javascript">
	var checked=false;
	var frmname='';
	function checkedAll(frmname){
	 var valus= document.getElementById(frmname);
	 if (checked==false){
	 	checked=true;
	 }else{
	 	checked = false;
	 }
	 for (var i =0; i < valus.elements.length; i++){
	 	valus.elements[i].checked=checked;
	 }
	}
	</script>	
<?php 
}
function html_script_reload(){
	?>
	<script type="text/javascript" src="./libs/jquery-latest.js"></script>
	<script src="style/chosen.jquery.js" type="text/javascript"></script>
	
	<script>
		/* function reload page*/
		function reLoad(){
			window.location.reload();
			history.go(0);
			window.location.href = window.location.href;
		}
	</script>
<?php 
}
/*
 * alarm script
 * */
function html_alarm_script(){
?>
<script type="text/javascript">
/*combobox status alarm change event*/
	$(document).ready(function() {
		$("#id_status_alarm").change(function(){
		 	//get current selected value of combobox
		 	var statusValue = $(this).val();
		 	var deviceValue = $("#id_host_alarm").val();
		 	 var searchFilter = $("#id_search").val();
		 	//build query string
		 	var queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&search="+searchFilter+"&id=0";
		 	document.location.href = "?"+queryString;
		});
		
		 $("#btnGo").click(function(){
			 	var deviceValue = $("#id_host_alarm").val();
			 	var statusValue = $("#id_status_alarm").val();
			 var searchFilter = $("#id_search").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&id=0"; 
			}
			else{
				queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&search="+searchFilter+"&id=0";
			} 
			 	document.location.href = "?"+queryString;
		 });
		 $("#btnClear"). click(function (){
				var deviceValue = "";
			 	var statusValue = "";
			 	var searchFilter = "";
				var clear = 'yes';		
			 queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&search="+searchFilter+"&clear="+clear+"&id=0";
			 document.location.href="?"+queryString;
		 });
		 $('#id_master_table tr').click(function(event) {
			    if (event.target.type !== 'checkbox') {
			      $(':checkbox', this).trigger('click');
			    }
			  });
		 $("#btnRefresh"). click(function (){
				window.location.reload();
				history.go(0);
				window.location.href = window.location.href;
		 });
			$('#nms-checkbox-checkall').click(function(){
				var trs = $('#id_master_table').find('tr:not(:eq(0))');
				var status;
				
				trs.each(function(key,tr){
					status  = $(tr).attr('data-status');
					if($('#nms-checkbox-checkall').is(':checked'))
					{
						switch (status){
							case '1': $(tr).removeClass('mautrangthaivuaDown');
							break;
							case '2': $(tr).removeClass('mautrangthaiDown');
							break;
							case '3': $(tr).removeClass('mautrangthaiUp');
							break;
							case '4': $(tr).removeClass('mautrangthaiNomal');
							break;
							case '5': $(tr).removeClass('mautrangthaiPause');
							break;
							case '6': $(tr).removeClass('mautrangthaiUnk');
							break;
						}
						$(tr).css('background-color','Silver  ');
					}
					else{
						switch (status){
							case '1': $(tr).addClass('mautrangthaivuaDown');
							break;
							case '2': $(tr).addClass('mautrangthaiDown');
							break;
							case '3': $(tr).addClass('mautrangthaiUp');
							break;
							case '4': $(tr).addClass('mautrangthaiNomal');
							break;
							case '5': $(tr).addClass('mautrangthaiPause');
							break;
							case '6': $(tr).removeClass('mautrangthaiUnk');
							break;
						}
						$(tr).css('background-color','');
					}
				});
			});	
		 
		 $(".cls-alarm-table-checkbox").click(function(){
	 		var tr = $(this).closest('tr');
			var status = $(tr).attr('data-status');
			if(this.checked)
			{
				switch (status){
					case '1': $(tr).removeClass('mautrangthaivuaDown');
					break;
					case '2': $(tr).removeClass('mautrangthaiDown');
					break;
					case '3': $(tr).removeClass('mautrangthaiUp');
					break;
					case '4': $(tr).removeClass('mautrangthaiNomal');
					break;
					case '5': $(tr).removeClass('mautrangthaiPause');
					break;
				}
				$(this).closest('tr').css('background-color','Silver  ');
			}
			else{
				switch (status){
					case '1': $(tr).addClass('mautrangthaivuaDown');
					break;
					case '2': $(tr).addClass('mautrangthaiDown');
					break;
					case '3': $(tr).addClass('mautrangthaiUp');
					break;
					case '4': $(tr).addClass('mautrangthaiNomal');
					break;
					case '5': $(tr).addClass('mautrangthaiPause');
					break;
				}
				$(this).closest('tr').css('background-color','');
			}
		});
	});
	function keydown(e){
		 if (!e) var e = window.event;
		 if (e.keyCode) code = e.keyCode;
		 else if (e.which) code = e.which;
		if (code==13){
			var deviceValue = $("#id_host_alarm").val();
		 	var statusValue = $("#id_status_alarm").val();
		 	var searchFilter = $("#id_search").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&id=0"; 
			}
			else{
				queryString = "run=alarm&filter="+statusValue+"&host_id="+deviceValue+"&search="+searchFilter+"&id=0";
			} 
		 		document.location.href = "?"+queryString;
			}
		}
	
</script>
<?php 
}
function html_alarm_script_time(){
?>
	<script type="text/javascript">
		/* Get date,month,year*/
		var mydate=new Date(); var year=mydate.getYear();
		if (year < 1000) year+=1900;
		var day=mydate.getDay();
		var month=mydate.getMonth(); var daym=mydate.getDate();
		if (daym<10) daym="0"+daym;
		var dayarray=new Array("Chủ nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy");
		var montharray=new Array("/1","/2","/3","/4","/5","/6","/7","/8","/9","/10","/11","/12");
		document.getElementById('countdown_time1').innerHTML =daym+""+montharray[month]+"/"+year+"<br>";
		</script>
		<script type="text/javascript">
		/* countdown time : 5 minute*/
		var hour = 0;
		var min = 4;
		var sec = 60;
		
		function countdown() {
			if(sec <= 0 && min > 0) {
				sec = 59;
				min -= 1;
			}
			else if(min <= 0 && sec <= 0) {
				min = 0;
				sec = 0;
			}
			else {
				sec -= 1;
			}
				
			if(min <= 0 && hour > 0) {
				min = 59;
				hour -= 1;
			}
				
			var pat = /^[0-9]{1}$/;
			sec = (pat.test(sec) == true) ? '0'+sec : sec;
			min = (pat.test(min) == true) ? '0'+min : min;
			hour = (pat.test(hour) == true) ? '0'+hour : hour;
			document.getElementById('countdown_time2').innerHTML = min+":"+sec;
			setTimeout("countdown()",1000);
			setTimeout(function () {
				location.href = 'nms.php?run=alarm&id=0'; 
			}, 300000);
		}
		countdown();
</script>
<?php 
}
function html_alarm_script_time1(){
	?>
	<script type="text/javascript">
		/* Get date,month,year*/
		var mydate=new Date(); var year=mydate.getYear();
		if (year < 1000) year+=1900;
		var day=mydate.getDay();
		var month=mydate.getMonth(); var daym=mydate.getDate();
		if (daym<10) daym="0"+daym;
		var dayarray=new Array("Chủ nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy");
		var montharray=new Array("/1","/2","/3","/4","/5","/6","/7","/8","/9","/10","/11","/12");
		document.getElementById('countdown_time3').innerHTML =daym+""+montharray[month]+"/"+year+"<br>";
		</script>
		<script type="text/javascript">
		/* countdown time : 5 minute*/
		var hour = 0;
		var min = 4;
		var sec = 60;
		
		function countdown() {
			if(sec <= 0 && min > 0) {
				sec = 59;
				min -= 1;
			}
			else if(min <= 0 && sec <= 0) {
				min = 0;
				sec = 0;
			}
			else {
				sec -= 1;
			}
				
			if(min <= 0 && hour > 0) {
				min = 59;
				hour -= 1;
			}
				
			var pat = /^[0-9]{1}$/;
			sec = (pat.test(sec) == true) ? '0'+sec : sec;
			min = (pat.test(min) == true) ? '0'+min : min;
			hour = (pat.test(hour) == true) ? '0'+hour : hour;
			document.getElementById('countdown_time4').innerHTML = min+":"+sec;
			setTimeout("countdown()",1000);
			setTimeout(function () {
				location.href = 'nms.php?run=alarm&id=0'; 
			}, 300000);
		}
		countdown();
</script>
	<?php 
}
/*
 * Log interface and device script
 * */
function html_log_interface_script(){
?>
<script>
	/*combobox status alarm change event*/
	$(document).ready(function() {
		$("#id_status_alarm1").change(function(){
		 	//get current selected value of combobox
		 	var statusValue = $(this).val();
		 	var deviceValue = $("#id_host_alarm1").val();
		 	 var searchFilter = $("#id_search1").val();
		 	var record= $("#id_status_alarm2").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		$("#id_status_alarm2").change(function(){
		 	//get current selected value of combobox
		 	var record = $(this).val();
		 	var deviceValue = $("#id_host_alarm1").val();
		 	 var searchFilter = $("#id_search1").val();
		 	var statusValue = $("#id_status_alarm1").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		$("#id_host_alarm1").change(function(){
		 	//get current selected value of combobox
		 	var deviceValue = $(this).val();
		 	var statusValue = $("#id_status_alarm1").val();
		 	var searchFilter = $("#id_search1").val();
		 	var record= $("#id_status_alarm2").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		 $("#btnGo1").click(function(){
			 	var deviceValue = $("#id_host_alarm1").val();
			 	var statusValue = $("#id_status_alarm1").val();
			 var searchFilter = $("#id_search1").val();
			 var record= $("#id_status_alarm2").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record; 
			}
			else{
				queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
			} 
			 	document.location.href = "?"+queryString;
		 });
		 $("#btnClear1"). click(function (){
				var deviceValue = '';
				var statusValue = '';
				var searchFilter = '';
				var record = '';
				 var clear = "yes";	
			 queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter+"&clear="+clear;
			 document.location.href="?"+queryString;
				   $("#id_host_alarm1").val('Any');
				   $("#id_status_alarm1").val('All');
				   $("#idsearch1").val('');
				   $("#id_status_alarm2").val('50');
			 
		 });
		 $("#btnRefresh1"). click(function (){
				window.location.reload();
				history.go(0);
				window.location.href = window.location.href;
		 });
	});
	function keydown(e){
		 if (!e) var e = window.event;
		 if (e.keyCode) code = e.keyCode;
		 else if (e.which) code = e.which;
		if (code==13){
			var deviceValue = $("#id_host_alarm1").val();
		 	var statusValue = $("#id_status_alarm1").val();
			var searchFilter = $("#id_search1").val();
		 	var record= $("#id_status_alarm2").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record; 
			}
			else{
				queryString = "run=log&tab=log_interface&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
			} 
			 	document.location.href = "?"+queryString;
		}
	}
	</script>
	<script type="text/javascript">
	<!--
	function pauseaudio(Eaudio){
		var audio = document.getElementById(Eaudio);
		audio.pause();
	}
	// function play audio
	//audio element\
	function playnow(audioElm){
		var audioElm = document.getElementById(audioElm);//audio element\
		audioElm.play();
	}
	function playAudio(n1,src1,n2,src2){
		var audio1 = "audio1";
		var audio2 = "audio2";
		var audioElm1 = document.getElementById(audio1);//audio element\
		var audioElm2 = document.getElementById(audio2);//audio element\
		var duration;
		var time = 0;
		//time delay between two sound
		var tDelay=500;
		//pause before play sound
		pauseaudio(audio1);
		pauseaudio(audio2);
		//play sound 1 and sound 2 
		if(src1 != "upload/No sound"){
			audioElm1.src = src1;
			audioElm1.addEventListener("loadedmetadata", function(_event) {
				if(n1 >0){
					playnow("audio1");
					duration = audioElm1.duration;
					for(var i=1;i<n1;i++){
						time = time + (duration*1000)+tDelay;
						setTimeout('playnow("audio1")',time);
					}
				}
				time = time+(duration*1000);
					//play sound 2
				if(n2 > 0){
					audioElm2.src = src2;
					audioElm2.addEventListener("loadedmetadata", function(_event) {
						duration = audioElm2.duration;
						time = time+tDelay;
						t2 = setTimeout('playnow("audio2")',time);
						for(var i=1;i<n2;i++){
							time = time +(duration*1000)+tDelay;
							t3 = setTimeout('playnow("audio2")',time);
						}
					});
				}
			});
		}
		else{
			//only play sound 2
			if(n2 > 0){
				audioElm2.src = src2;
				audioElm2.addEventListener("loadedmetadata", function(_event) {
					duration = audioElm2.duration;
					time = time+tDelay;
					t2 = setTimeout('playnow("audio2")',time);
					for(var i=1;i<n2;i++){
						time = time +(duration*1000)+tDelay;
						t3 = setTimeout('playnow("audio2")',time);
					}
				});
			}
		}
		
	} 
</script>
<?php 
}
function html_interface_script_time(){
	?>
		<script type="text/javascript">
		/* Get date,month,year*/
				  var mydate=new Date(); var year=mydate.getYear();   
	                if (year < 1000) year+=1900;
	                var day=mydate.getDay(); 
	                var month=mydate.getMonth(); var daym=mydate.getDate(); 
	                if (daym<10) daym="0"+daym;
	                var dayarray=new Array("Chủ nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy"); 
	                var montharray=new Array("/1","/2","/3","/4","/5","/6","/7","/8","/9","/10","/11","/12");			 
				 document.getElementById('countdown_time1').innerHTML =daym+""+montharray[month]+"/"+year+"<br>";
		</script>
		<script type="text/javascript">
		/* countdown time : 5 minute*/
				 var hour = 0;
				 var min = 4;
				 var sec = 60;
				
				function countdown() {
				 if(sec <= 0 && min > 0) {
				  sec = 59;
				  min -= 1;
				 }
				 else if(min <= 0 && sec <= 0) {
				  min = 0;
				  sec = 0;
				 }
				 else {
				  sec -= 1;
				 }
				 
				 if(min <= 0 && hour > 0) {
				  min = 59;
				  hour -= 1;
				 }
				 
				 var pat = /^[0-9]{1}$/;
				 sec = (pat.test(sec) == true) ? '0'+sec : sec;
				 min = (pat.test(min) == true) ? '0'+min : min;
				 hour = (pat.test(hour) == true) ? '0'+hour : hour;
				 document.getElementById('countdown_time2').innerHTML = min+":"+sec;
				 setTimeout("countdown()",1000);
				 setTimeout(function () {
					    location.href = 'nms.php?run=log&tab=log_interface&id=0'; 
					}, 300000);
				 }
				 countdown();
		</script>
<?php 
}
function html_log_device_script(){
?>
<script>
	/*combobox status alarm change event*/
	$(document).ready(function() {
		$("#id_status_alarm1").change(function(){
		 	//get current selected value of combobox
		 	var statusValue = $(this).val();
		 	var deviceValue = $("#id_host_alarm1").val();
		 	 var searchFilter = $("#id_search1").val();
		 	var record= $("#id_status_alarm2").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		$("#id_status_alarm2").change(function(){
		 	//get current selected value of combobox
		 	var record = $(this).val();
		 	var deviceValue = $("#id_host_alarm1").val();
		 	 var searchFilter = $("#id_search1").val();
		 	var statusValue = $("#id_status_alarm1").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		$("#id_host_alarm1").change(function(){
		 	//get current selected value of combobox
		 	var deviceValue = $(this).val();
		 	var statusValue = $("#id_status_alarm1").val();
		 	var searchFilter = $("#id_search1").val();
		 	var record= $("#id_status_alarm2").val();
		 	//build query string
		 	var queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		 $("#btnGo1").click(function(){
			 	var deviceValue = $("#id_host_alarm1").val();
			 	var statusValue = $("#id_status_alarm1").val();
			 var searchFilter = $("#id_search1").val();
			 var record= $("#id_status_alarm2").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record; 
			}
			else{
				queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
			} 
			 	document.location.href = "?"+queryString;
		 });
		 $("#btnClear1"). click(function (){
				var deviceValue = '';
				var statusValue = '';
				var searchFilter = '';
				var record = '';		
			 queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter+"&clear=yes";
			 document.location.href="?"+queryString;
				   $("#id_host_alarm1").val('Any');
				   $("#id_status_alarm1").val('All');
				   $("#idsearch1").val('');
				   $("#id_status_alarm2").val('50');
			 
		 });
		 $("#btnRefresh1"). click(function (){
				window.location.reload();
				history.go(0);
				window.location.href = window.location.href;
		 });
	});
	function keydown(e){
		 if (!e) var e = window.event;
		 if (e.keyCode) code = e.keyCode;
		 else if (e.which) code = e.which;
		if (code==13){
			var deviceValue = $("#id_host_alarm1").val();
		 	var statusValue = $("#id_status_alarm1").val();
		 	var record = $("#id_status_alarm2").val();
		 	var searchFilter = $("#id_search1").val();
			var queryString = '';
			if(searchFilter==''){
				queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record; 
			}
			else{
				queryString = "run=log&tab=log_device&id=0&filter="+statusValue+"&host_id="+deviceValue+"&record="+record+"&search="+searchFilter;
			} 
		 		document.location.href = "?"+queryString;
			}
		}
</script>
<?php 
}
function html_logdevice_script_time(){
?>
		<script type="text/javascript">
		/* Get date,month,year*/
				  var mydate=new Date(); var year=mydate.getYear();   
	                if (year < 1000) year+=1900;
	                var day=mydate.getDay(); 
	                var month=mydate.getMonth(); var daym=mydate.getDate(); 
	                if (daym<10) daym="0"+daym;
	                var dayarray=new Array("Chủ nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy"); 
	                var montharray=new Array("/1","/2","/3","/4","/5","/6","/7","/8","/9","/10","/11","/12");			 
				 document.getElementById('countdown_time1').innerHTML =daym+""+montharray[month]+"/"+year+"<br>";
		</script>
		<script type="text/javascript">
		/* countdown time : 5 minute*/
				 var hour = 0;
				 var min = 4;
				 var sec = 60;
				
				function countdown() {
				 if(sec <= 0 && min > 0) {
				  sec = 59;
				  min -= 1;
				 }
				 else if(min <= 0 && sec <= 0) {
				  min = 0;
				  sec = 0;
				 }
				 else {
				  sec -= 1;
				 }
				 
				 if(min <= 0 && hour > 0) {
				  min = 59;
				  hour -= 1;
				 }
				 
				 var pat = /^[0-9]{1}$/;
				 sec = (pat.test(sec) == true) ? '0'+sec : sec;
				 min = (pat.test(min) == true) ? '0'+min : min;
				 hour = (pat.test(hour) == true) ? '0'+hour : hour;
				 document.getElementById('countdown_time2').innerHTML = min+":"+sec;
				 setTimeout("countdown()",1000);
				 setTimeout(function () {
					    location.href = 'nms.php?run=log&tab=log_device&id=0'; 
					}, 300000);
				 }
				 countdown();
		</script>
<?php 
}
/*
 * Interface management script  
 */
function html_interface_manage_script(){
?>
<script>
	$(document).ready(function() {
		$("#id_devices").change(function(){
		 	//get current selected value of combobox
		 	var devices = $(this).val();
		 	 var searchFilter = $("#id_search").val();
		 	var alias = $("#id_alias").val(); 	 
		 	//build query string
		 	var queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		$("#id_alias").change(function(){
		 	//get current selected value of combobox
		 	var alias =  $(this).val();
		 	var devices = $("#id_devices").val();
		 	 var searchFilter = $("#id_search").val();
		 	//build query string
		 	var queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
		 $('#id_master_table tr').click(function(event) {
			    if (event.target.type !== 'checkbox') {
			      $(':checkbox', this).trigger('click');
			    }
		   });
	 $(".cls-alarm-table-checkbox").click(function(){
 		var tr = $(this).closest('tr');
		var status = $(tr).attr('data-status');
		if(this.checked)
		{
			switch (status){
				case '1': $(tr).removeClass('xanhlot');
				break;
				case '2': $(tr).removeClass('xanhdam');
				break;
			}
			$(this).closest('tr').css('background-color','Silver');
		}
		else{
			switch (status){
				case '1': $(tr).addClass('xanhlot');
				break;
				case '2': $(tr).addClass('xanhdam');
				break;
			}
			$(this).closest('tr').css('background-color','');
		}
	});
	 $('#nms-checkbox-checkall').click(function(){
			var trs = $('#id_master_table').find('tr:not(:eq(0))');
			var status;
			
			trs.each(function(key,tr){
				status  = $(tr).attr('data-status');
				if($('#nms-checkbox-checkall').is(':checked'))
				{
					switch (status){
						case '1': $(tr).removeClass('xanhlot');
						break;
						case '2': $(tr).removeClass('xanhdam');
						break;
					}
					$(tr).css('background-color','Silver');
				}
				else{
					switch (status){
						case '1': $(tr).addClass('xanhlot');
						break;
						case '2': $(tr).addClass('xanhdam');
						break;
					}
					$(tr).css('background-color','');
				}
			});
		});	
	});
	function keydown(e){
		 if (!e) var e = window.event;
		 if (e.keyCode) code = e.keyCode;
		 else if (e.which) code = e.which;
			if (code==13){
				var devices = $("#id_devices").val();
				var alias = $("#id_alias").val();
		 		var searchFilter = $("#id_search").val();
			var queryString = '';
			if(searchFilter==''){
				 queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias;
			}
			else{
				 queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias+"&search="+searchFilter;
			} 
		 		document.location.href = "?"+queryString;
			}
		}

//-->
</script>
<?php 
}

function html_interface_script_reload(){
	?>
<script type="text/javascript">
<!--
function reLoad1(){
	var devices = $("#id_devices").val();
	var alias = $("#id_alias").val();
		var searchFilter = $("#id_search").val();
	var queryString = '';
	if(searchFilter==''){
		 queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias;
	}
	else{
		 queryString = "run=group&tab=group_interface&host_id="+devices+"&alias="+alias+"&search="+searchFilter;
	} 
	window.location.href = "?"+queryString;
	location.href ="?"+queryString;
}
//-->
</script>
	<?php 
}
/*
 *  Group interface script
 * */
function html_group_interface_manage_script(){
?>
	<script>
<!--
	$(document).ready(function() {
		$("#id_group").change(function(){
		 	//get current selected value of combobox
		 	var group = $(this).val();
		 	 var searchFilter = $("#id_search").val();
		 	//build query string
		 	var queryString = "run=group&tab=group_view&group_name="+group+"&search="+searchFilter;
		 	document.location.href = "?"+queryString;
		});
	});
	function keydown(e){
	 if (!e) var e = window.event;
	 if (e.keyCode) code = e.keyCode;
	 else if (e.which) code = e.which;
		if (code==13){
		 	var group = $("#id_group").val();
	 		var searchFilter = $("#id_search").val();
		var queryString = '';
		if(searchFilter==''){
			 queryString = "run=group&tab=group_view&group_name="+group;
		}
		else{
			 queryString = "run=group&tab=group_view&group_name="+group+"&search="+searchFilter;
		} 
	 		document.location.href = "?"+queryString;
		}
	}
//-->
</script>
<?php 
}
function html_group_interface_script_reload(){
	?>
<script type="text/javascript">
<!--
function reLoad(){
	var group = $("#id_group").val();
		var searchFilter = $("#id_search").val();
	var queryString = '';
	if(searchFilter==''){
		 queryString = "run=group&tab=group_view&group_name="+group;
	}
	else{
		 queryString = "run=group&tab=group_view&group_name="+group+"&search="+searchFilter;
	} 
	window.location.href = "?"+queryString;
	location.href ="?"+queryString;
}
//-->
</script>
	<?php 
}
/*
 * group phone script
 * */
function html_group_phone_script(){
?>
<script>
	$(document).ready(function() {
		$("#id_group").change(function(){
		 	//get current selected value of combobox
		 	var group = $(this).val();	 
		 	//build query string
		 	var queryString = "run=group&tab=group_phone&group_name="+group;
		 	document.location.href = "?"+queryString;
		});
		 $('#id_group_left_center tr').click(function(event) {
			    if (event.target.type !== 'checkbox') {
			      $(':checkbox', this).trigger('click');
			    }
		   });
		 $('#id_group_right tr').click(function(event) {
			    if (event.target.type !== 'checkbox') {
			      $(':checkbox', this).trigger('click');
			    }
		   });
		 $(".cls-alarm-table-checkbox").click(function(){
		 		var tr = $(this).closest('tr');
				var status = $(tr).attr('data-status');
				if(this.checked)
				{
					switch (status){
						case '1': $(tr).removeClass('xanhlot');
						break;
						case '2': $(tr).removeClass('xanhhong');
						break;
					}
					$(this).closest('tr').css('background-color','Silver');
				}
				else{
					switch (status){
						case '1': $(tr).addClass('xanhlot');
						break;
						case '2': $(tr).addClass('xanhhong');
						break;
					}
					$(this).closest('tr').css('background-color','');
				}
			});
		 
	});
</script>
<?php
}
	function html_group_phone_script_reload(){
?>
	<script>
	function reLoad1(){
 		var group = $("#id_group").val();
		var queryString = '';
		 queryString = "run=group&tab=group_phone&group_name="+group;
		window.location.href = "?"+queryString;
		location.href ="?"+queryString;
	}
</script>
<?php 
	}
/*
 * setting script
 * */
function html_setting_script_reload(){
?>
	<script>
		function reLoad1(){
			window.location.href = 'nms.php?run=setting';
			location.href = 'nms.php?run=setting';
		}
	</script>
<?php 
}

/*
 * device management script
 * */
function html_device_script_popup(){
?>
<script type="text/javascript"> 
	$(document).ready(function() {
	    $(".popup").hide();
	 
	    $(".button1").click(function(e) {
	        //openPopup(1);
	    });
	 
	    $(".close").click(function (e) {
	        closePopup();
	        e.preventDefault();
	    });
	 
	    $("#background").click(function () {
	        closePopup();
	    });
	 
	});
	 
	function openPopup($id){
	    var dheight = document.body.clientHeight;
	    var dwidth = document.body.clientWidth;
	 
	    $("#background").width(dwidth).height(dheight);
	 
	    $("#background").fadeTo("slow",0.8);
	 
	    var $popup1=$("#popup"+$id);
	    $popup1.css("top", (dheight-$popup1.height())/2);
	    $popup1.css("left",(dwidth-$popup1.width())/2);		 
	    $popup1.fadeIn();
	}
	function closePopup(){
	    $("#background").fadeOut();
	    $(".popup").hide();
	}
 	 </script>
<?php 
	}
	
	function html_device_script(){
		?>
	 <script>
	$(document).ready(function() {
	/*combobox  Device Manage Information change event*/
		/*$("#id_select_report").change(function(){
		 	//get current selected value of combobox
		 	var deviceValue = $("#id_host_dim").val();
		 	var statusValue = $("#id_time_dim").val();
		 	var searchFilter = $("#id_search").val();
		 	var select = $(this).val();
		 	var date = $("#date").val();
		 	//build query string
		 	var queryString = "run=dim&date="+date+"&host_id="+deviceValue+"&search="+searchFilter+"&select="+select;
		 	document.location.href = "?"+queryString;
		});*/
	/*Button Go change event*/
		 $("#btnGo").click(function(){
			 	var deviceValue = $("#id_host_dim").val();
			 	var searchFilter = $("#id_search").val();
				var date = $("#date").val();
				queryString = "run=dim&date="+date+"&host_id="+deviceValue+"&search="+searchFilter;
			 	document.location.href = "?"+queryString;
		 });
	/*Button Clear change event*/
		 $("#btnClear"). click(function (){
			 	var deviceValue = '';
			 	var searchFilter = '';
				var date = '';
				var report = '';
				queryString = "run=dim&date="+date+"&host_id="+deviceValue+"&select="+report+"&search"+searchFilter+"&clear=yes";
			 	document.location.href = "?"+queryString;
			 
		 });
		 $("#btnExport1"). click(function (){
				var deviceValue = $("#id_host_dim").val();
			 	var date = $("#date").val();
			 	var report = $("#id_select_report").val();
				queryString = "run=dim&date="+date+"&host_id="+deviceValue+"&select="+report+"&export=dim";
			 	document.location.href = "?"+queryString;
		 });
	/*Button Refresh change event*/
		 $("#btnRefresh"). click(function (){
			var deviceValue= $("#id_host_dim").val();
			queryString = "run=dim&refreshid="+deviceValue;
			document.location.href="?"+queryString;
		 });
	});
	function keydown(e){
		 if (!e) var e = window.event;
		 if (e.keyCode) code = e.keyCode;
		 else if (e.which) code = e.which;
		if (code==13){
		 	var deviceValue = $("#id_host_dim").val();
		 	var date = $("#date").val();
		 	var searchFilter = $("#id_search").val();
			queryString = "run=dim&date="+date+"&host_id="+deviceValue+"&search="+searchFilter; 
			 	document.location.href = "?"+queryString;
			}
		}
</script>
		<?php 
	}
	function html_script_module_report(){
?>
	<script type="text/javascript" src="./libs/jquery.min.js"></script>
	<script type="text/javascript" src="./libs/jquery-latest.js"></script>
	<script type="text/javascript" src="./libs/jquery.highlight-4.js"></script>
	<script src="style/chosen.jquery.js" type="text/javascript"></script>
	<script type="text/javascript">
		function getQueryStrings() { 
			  var assoc  = {};
			  var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
			  var queryString = location.search.substring(1); 
			  var keyValues = queryString.split('&'); 
		
			  for(var i in keyValues) { 
			    var key = keyValues[i].split('=');
			    if (key.length > 1) {
			      assoc[decode(key[0])] = decode(key[1]);
			    }
			  } 
			  return assoc; 
			}	
		
	</script>
	
	<!-- Script call  device filter, search ---------------> 	 
	<script>
	function highlight(container,what,spanClass) {
	    var content = container.innerHTML,
	        pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
	        replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
	        highlighted = content.replace(pattern,replaceWith);
	    return (container.innerHTML = highlighted) !== content;
	}
		$(document).ready(function() {
			$("#id_module").change(function(){
			 	//get current selected value of combobox
			 	var module =$(this).val();
			 	var hmodule =  $("#id_host_report").val();
			 	var presents =$("#id_presets_module").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_host_report").change(function(){
			 	//get current selected value of combobox
			 	var hmodule = $(this).val();
			 	var module =$("#id_module").val();
			 	var presents =$("#id_presets_module").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_host").change(function(){
			 	//get current selected value of combobox
			 	var id = $(this).val();
			 	var hmodule = $("#id_host_report").val();
			 	var module =$("#id_module").val();
			 	var presents =$("#id_presets_module").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&id_hs="+id+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_presets_module").change(function(){
			 	//get current selected value of combobox
			 	var presents = $(this).val();
			 	var hmodule = $("#id_host_report").val();
			 	var filter =$("#id_filter_module").val();
			 	var module =$("#id_module").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#btnGo1"). click(function (){
			 	//get current selected value of combobox
			 	//var LimitValue = $("id_limit_report").val();
			 	var hmodule = $("#id_host_report").val();
			 	var presents =$("#id_presets_module").val();
			 	var date_from = $("#date").val();
			 	var date_to = $("#date_2").val();
			 	var module =$("#id_module").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&presets="+presents+"&datefrom="+date_from+"&dateto="+date_to+"&export=module";
			 	document.location.href = "?"+queryString;
			});
			$("#btnClear1"). click(function (){
				var hmodule = '';
			 	var presents ='';
			 	var module ='';
			 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module+"&presets="+presents;
			 	document.location.href = "?"+queryString;
		 });
		/*Button Refresh change event*/
			 $("#btnRefresh"). click(function (){
					window.location.reload();
					history.go(0);
					window.location.href = window.location.href;
			 });
		});
	</script>
<?php 
	}
	function html_reload_module_report(){
?>
	<script>
		function reLoad1(){
			var hmodule = $("#id_host_report").val();
		 	var module =$("#id_module").val();
		 	//build query string
		 	var queryString = "run=report_device&tab=module&hmodule="+hmodule+"&module="+module;
			location.href ="?"+queryString;
		}
	</script>
<?php 
	}
	function  html_script_port_report(){
?>
	<script type="text/javascript" src="./libs/jquery.min.js"></script>
	<script type="text/javascript" src="./libs/jquery-latest.js"></script>
	<script type="text/javascript" src="./libs/jquery.highlight-4.js"></script>
	<script src="style/chosen.jquery.js" type="text/javascript"></script>
	<script type="text/javascript">
		function getQueryStrings() { 
			  var assoc  = {};
			  var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
			  var queryString = location.search.substring(1); 
			  var keyValues = queryString.split('&'); 
		
			  for(var i in keyValues) { 
			    var key = keyValues[i].split('=');
			    if (key.length > 1) {
			      assoc[decode(key[0])] = decode(key[1]);
			    }
			  } 
			  return assoc; 
			}	
		
	</script>
	
	<!-- Script call  device filter, search ---------------> 	 
	<script>
	function highlight(container,what,spanClass) {
	    var content = container.innerHTML,
	        pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
	        replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
	        highlighted = content.replace(pattern,replaceWith);
	    return (container.innerHTML = highlighted) !== content;
	}
		$(document).ready(function() {
			$("#id_port").change(function(){
			 	//get current selected value of combobox
			 	var port =$(this).val();
			 	var hport =  $("#id_host_report").val();
			 	var presents =$("#id_presets_port").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_host_report").change(function(){
			 	//get current selected value of combobox
			 	var hport = $(this).val();
			 	var port =$("#id_port").val();
			 	var presents =$("#id_presets_port").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_host").change(function(){
			 	//get current selected value of combobox
			 	var id = $(this).val();
			 	var hport = $("#id_host_report").val();
			 	var port =$("#id_port").val();
			 	var presents =$("#id_presets_port").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&id_hs="+id+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#id_presets_port").change(function(){
			 	//get current selected value of combobox
			 	var presents = $(this).val();
			 	var hport = $("#id_host_report").val();
			 	var filter =$("#id_filter_port").val();
			 	var port =$("#id_port").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&presets="+presents;
			 	document.location.href = "?"+queryString;
			});
			$("#btnGo1"). click(function (){
			 	//get current selected value of combobox
			 	//var LimitValue = $("id_limit_report").val();
			 	var hport = $("#id_host_report").val();
			 	var presents =$("#id_presets_port").val();
			 	var date_from = $("#date").val();
			 	var date_to = $("#date_2").val();
			 	var port =$("#id_port").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&presets="+presents+"&datefrom="+date_from+"&dateto="+date_to+"&export=port";
			 	document.location.href = "?"+queryString;
			});
			$("#btnClear1"). click(function (){
				var hport = '';
			 	var presents ='';
			 	var port ='';
			 	//build query string
			 	var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port+"&presets="+presents;
			 	document.location.href = "?"+queryString;
		 });
		/*Button Refresh change event*/
			 $("#btnRefresh"). click(function (){
					window.location.reload();
					history.go(0);
					window.location.href = window.location.href;
			 });
		});
	</script>
<?php 
	}
	function html_reload_port_report(){
?>
	<script>
		function reLoad1(){
			var hport = $("#id_host_report").val();
		 	var port =$("#id_port").val();
		 	//build query string
			var queryString = "run=report_device&tab=port&hport="+hport+"&port="+port;
			window.location.href = "?"+queryString;
			location.href ="?"+queryString;
		}
	</script>
<?php
	}
	function html_script_trans_report(){
		?>
		<script type="text/javascript" src="./libs/jquery.min.js"></script>
		<script type="text/javascript" src="./libs/jquery-latest.js"></script>
		<script type="text/javascript" src="./libs/jquery.highlight-4.js"></script>
		<script src="style/chosen.jquery.js" type="text/javascript"></script>
		<script type="text/javascript">
			function getQueryStrings() { 
				  var assoc  = {};
				  var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
				  var queryString = location.search.substring(1); 
				  var keyValues = queryString.split('&'); 
			
				  for(var i in keyValues) { 
				    var key = keyValues[i].split('=');
				    if (key.length > 1) {
				      assoc[decode(key[0])] = decode(key[1]);
				    }
				  } 
				  return assoc; 
				}	
			
		</script>
		
		<!-- Script call  device filter, search ---------------> 	 
		<script>
		function highlight(container,what,spanClass) {
		    var content = container.innerHTML,
		        pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
		        replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
		        highlighted = content.replace(pattern,replaceWith);
		    return (container.innerHTML = highlighted) !== content;
		}
			$(document).ready(function() {
				$("#id_host_report").change(function(){
				 	//get current selected value of combobox
				 	var htrans = $(this).val();
				 	var strans =$("#id_group_interface").val();
				 	var presents =$("#id_presets_trans").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents;
				 	document.location.href = "?"+queryString;
				});
				$("#id_group_interface").change(function(){
				 	//get current selected value of combobox
				 	var strans =$(this).val();
				 	var htrans = $("#id_host_report").val();
				 	var presents =$("#id_presets_trans").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents;
				 	document.location.href = "?"+queryString;
				});
				$("#id_host").change(function(){
				 	//get current selected value of combobox
				 	var id = $(this).val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	var presents =$("#id_presets_trans").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&id_hs="+id+"&presets="+presents;
				 	document.location.href = "?"+queryString;
				});
				$("#id_group").change(function(){
				 	//get current selected value of combobox
				 	var id = $(this).val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	var presents =$("#id_presets_trans").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&id_gr="+id+"&presets="+presents;
				 	document.location.href = "?"+queryString;
				});
				$("#id_presets_trans").change(function(){
				 	//get current selected value of combobox
				 	var presents = $(this).val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	var filter =$("#id_filter_trans").val();
				 	if(filter==1){
				 		var th = $("#id_thold_trans").val();
					}
					if(filter==2){
						var th =$("#id_rvalue_trans").val();
					}
					if(filter==3){
						var th =$("#id_limit_trans").val();
					}
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter+"&th="+th;
				 	document.location.href = "?"+queryString;
				});
				$("#id_filter_trans").change(function(){
				 	//get current selected value of combobox
				 	var filter = $(this).val();
				 	var presents =$("#id_presets_trans").val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter;
				 	document.location.href = "?"+queryString;
				});
				$("#id_thold_trans").change(function(){
				 	//get current selected value of combobox
				 	var th = $(this).val();
				 	var filter =$("#id_filter_trans").val();
				 	var presents =$("#id_presets_trans").val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter+"&th="+th;
				 	document.location.href = "?"+queryString;
				});
				$("#id_rvalue_trans").change(function(){
				 	//get current selected value of combobox
				 	var th = $(this).val();
				 	var filter =$("#id_filter_trans").val();
				 	var presents =$("#id_presets_trans").val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter+"&th="+th;
				 	document.location.href = "?"+queryString;
				});
				$("#id_limit_trans").change(function(){
				 	//get current selected value of combobox
				 	var th = $(this).val();
				 	var filter =$("#id_filter_trans").val();
				 	var presents =$("#id_presets_trans").val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter+"&th="+th;
				 	document.location.href = "?"+queryString;
				});
				$("#btnGo1"). click(function (){
				 	//get current selected value of combobox
				 	//var LimitValue = $("id_limit_report").val();
				 	var strans =$("#id_group_interface").val();
				 	var htrans = $("#id_host_report").val();
				 	var presents =$("#id_presets_trans").val();
				 	var date_from = $("#date").val();
				 	var date_to = $("#date_2").val();
				 	var filter =$("#id_filter_trans").val();
				 	if(filter==1){
				 		var th = $("#id_thold_trans").val();
					}
					if(filter==2){
						var th =$("#id_rvalue_trans").val();
					}
					if(filter==3){
						var th =$("#id_limit_trans").val();
					}
				 	//build query string
				 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&datefrom="+date_from+"&dateto="+date_to+"&fil="+filter+"&th="+th+"&export=trans";
				 	document.location.href = "?"+queryString;
				});
				$("#btnClear1"). click(function (){
					var strans ='';
				 	var htrans = '';
				 	var presents ='';
				 	var filter ='';
					var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans+"&presets="+presents+"&fil="+filter;
				 	document.location.href = "?"+queryString;
			 });
			/*Button Refresh change event*/
				 $("#btnRefresh"). click(function (){
						window.location.reload();
						history.go(0);
						window.location.href = window.location.href;
				 });
			});
		</script>
		<?php 
	}
	function html_reload_trans_report(){
		?>
		<script>
			function reLoad1(){
				var strans =$("#id_group_interface").val();
			 	var htrans = $("#id_host_report").val();
			 	//build query string
			 	var queryString = "run=report_device&tab=trans&htrans="+htrans+"&strans="+strans;
				location.href ="?"+queryString;
			}
		</script>
		<?php 
	}
	function html_log_system_script(){
		?>
	<script>
		/*combobox status alarm change event*/
		$(document).ready(function() {
			$("#id_action_log_nms").change(function(){
			 	//get current selected value of combobox
			 	var action = $(this).val();
			 	 var searchFilter = '';
			 	var record= $("#id_record").val();
			 	//build query string
			 	var queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record+"&search="+searchFilter;
			 	document.location.href = "?"+queryString;
			});
			$("#id_record").change(function(){
			 	//get current selected value of combobox
			 	var record = $(this).val();
			 	var action = $("#id_action_log_nms").val();
			 	 var searchFilter = $("#id_search1").val();
			 	//build query string
			 	var queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record+"&search="+searchFilter;
			 	document.location.href = "?"+queryString;
			});
			 $("#btnGo1").click(function(){
				var action = '';
				var searchFilter = $("#id_search1").val();
				var record = $("#id_record").val();
				var queryString = '';
				if(searchFilter==''){
					 queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record;
				}
				else{
					 queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record+"&search="+searchFilter;
				} 
				 	document.location.href = "?"+queryString;
			 });
			 $("#btnClear1"). click(function (){
				 var action = '';
			 	 var searchFilter ='';
			 		var record = '';	
			 		queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record+"&search="+searchFilter;
				 document.location.href="?"+queryString;
					   $("#idsearch1").val('');
					   $("#id_status_alarm2").val('50');		 
			 });
			 $("#btnRefresh1"). click(function (){
					window.location.reload();
					history.go(0);
					window.location.href = window.location.href;
			 });
		});
		function keydown(e){
			 if (!e) var e = window.event;
			 if (e.keyCode) code = e.keyCode;
			 else if (e.which) code = e.which;
			if (code==13){
				var action = '';
				var searchFilter = $("#id_search1").val();
				var record = $("#id_record").val();
				var queryString = '';
				if(searchFilter==''){
					 queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record;
				}
				else{
					 queryString = "run=log&tab=log_system&id=0&filter="+action+"&record="+record+"&search="+searchFilter;
				} 
				 	document.location.href = "?"+queryString;
				}
			}
	</script>
	<?php 
	}
?>